/* Flash algorithm for MM32SPIN Flash Options(512B)
 *
 * DAPLink Interface Firmware
 * Copyright (c) 2009-2024 Arm Limited, All Rights Reserved
 * SPDX-License-Identifier: Apache-2.0
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

// Generated from 'MM32SPIN_OPT.FLM' (MM32SPIN Flash Options(512B))
// digest = 2067933eca5fe8b6c741704790b708d2cd5d52ab66b4993f07ea00eb79613944, file size = 11416
// algo version = 0x101, algo size = 400 (0x190)
#include "flash_blob.h"

static const uint32_t MM32SPIN_OPT_flash_prog_blob[] = {
    0xe7fdbe00,
    0x4858b530, 0x074a69c1, 0xd4054957, 0x600a4a57, 0x604a2206, 0x608a4a56, 0x60022200, 0x60444c55,
    0x60434b55, 0xe0004a55, 0x6905600a, 0xd4fb062d, 0x60836084, 0x600ae000, 0x059b6903, 0x2000d5fb,
    0x4848bd30, 0x15426901, 0x61014391, 0x22806901, 0x61014311, 0x47702000, 0x4842b530, 0x61444c48,
    0x23206901, 0x61014319, 0x22406901, 0x61014311, 0x4a3d4942, 0x6011e000, 0x07ed68c5, 0x6905d1fb,
    0x6105439d, 0x23106905, 0x6105431d, 0x80254d3d, 0x6011e000, 0x07e468c4, 0x6901d1fb, 0x61014399,
    0x211468c2, 0xd004420a, 0x430a68c2, 0x200160c2, 0x2000bd30, 0xb510bd30, 0x4931482a, 0x69026141,
    0x430a2120, 0x69026102, 0x431a2340, 0x4a2b6102, 0xe0004b25, 0x68c4601a, 0xd1fb07e4, 0x438a6902,
    0x20006102, 0x2001bd10, 0xb5f04770, 0x4b1d4694, 0x615a4a23, 0x2220691c, 0x611c4314, 0x2540691c,
    0x611c432c, 0x4d184c1d, 0x602ce000, 0x07f668de, 0x691ed1fb, 0x611e4396, 0x08491c49, 0x22100049,
    0xe01a2614, 0x4317691f, 0x4667611f, 0x8007883f, 0x602ce000, 0x07ff68df, 0x691fd1fb, 0x611f4397,
    0x423768df, 0x68d8d004, 0x60d84330, 0xbdf02001, 0x1cbf4667, 0x46bc1c80, 0x29001e89, 0x2000d1e2,
    0x0000bdf0, 0x40022000, 0x40003000, 0x00005555, 0x00000fff, 0x45670123, 0xcdef89ab, 0x0000aaaa,
    0x1ffff800, 0x00005aa5, 0x00000000};

// Start address of flash
#define MM32SPIN_OPT_flash_start 0x1ffff800
// Size of flash
#define MM32SPIN_OPT_flash_size 0x00000200
// Size of sector
#define MM32SPIN_OPT_sector_size 0x00000200

static const program_target_t MM32SPIN_OPT_flash = {
    0x20000005, // Init
    0x20000047, // UnInit
    0x2000005d, // EraseChip
    0x200000bb, // EraseSector
    0x200000ef, // ProgramPage
    0x00000000, // Verify

    // BKPT : start of blob + 1
    // RSB  : blob start + header + rw data offset
    // RSP  : stack pointer
    {
        0x20000001,
        0x2000018c,
        0x20000a00,
    },

    // mem buffer location
    0x20000a00,
    // location to write prog_blob in target RAM
    0x20000000,
    // prog_blob size
    sizeof(MM32SPIN_OPT_flash_prog_blob),
    // address of prog_blob
    MM32SPIN_OPT_flash_prog_blob,
    // ram_to_flash_bytes_to_be_written
    0x00000200,
};
